<template>
  <el-upload
    v-model:file-list="fileList"
    :action="data.url"
    list-type="picture-card"
    :on-preview="handlePictureCardPreview"
    :on-remove="handleRemove"
    name="upload"
  >
    <el-icon><Plus /></el-icon>
  </el-upload>

  <el-dialog v-model="dialogVisible">
    <img w-full :src="dialogImageUrl" alt="Preview Image" />
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref,reactive } from 'vue'
import { Plus } from '@element-plus/icons-vue'
import URL from '@/api/url.js'
import type { UploadProps, UploadUserFile } from 'element-plus'
const data = reactive({
  url:URL()+'/photo/addPhoto'
})
const fileList = ref<UploadUserFile[]>([
  
])

const dialogImageUrl = ref('')
const dialogVisible = ref(false)

const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
  console.log(uploadFile, uploadFiles)
}

const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
  dialogImageUrl.value = uploadFile.url!
  dialogVisible.value = true
}
</script>
